<?php

namespace app\api\controller;
use app\api\logic\ApiStockUpLogic;
use app\api\logic\LinXingOrderLogic;
use app\api\logic\TeamLogic;
use  app\common\controller\DBase;
use app\common\controller\PCBase;
use app\api\logic\TestLogic;
use app\api\logic\FreightLogic;
use app\api\logic\ShopyLogic;
use app\api\logic\checkLogic;
use app\common\service\CommonExportCsvTaskLogService;
use app\common\service\JinyiApiService;
use app\customer\logic\OrderRefundLogic;
use app\delivery\logic\DeliveryLogic;
use app\listing\logic\ShopifyListingLogic;
use app\order\logic\OrderReportSkuLogic;
use app\order\logic\OrderCheckLogisticsLogic;
use app\order\logic\OrderLogic;
use app\order\logic\OrderShipServiceLogic;
use app\order\logic\OrderSplitLogic;
use app\systems\logic\MqTaskServiceLogic;

class Test extends DBase
{
    /**
     * @desc  测试时间
     * @author xx
     * @date  2024-04-07
     */
    public function uploadTimeTest(){
        $file   = $this->request->file('file');
        $tel    = $this->getAdminTel();
        $data['file'] = $file;
        $data['tel']  = $tel;
        return    (new TestLogic())->uploadExcelTest($data);
    }


    /**
     * @desc   详情数据写入表
     * @author xx
     * @date 2024-03-18
     */
    public function importTest(){
        $data   = $this->request->post();
        (new MqTaskServiceLogic())->sale_center_system_import_task_detail($data);
        return $this->jsonMessage(200, true, "推送成功!", null);
    }


    /**
     * @desc   测试消费详情表数据
     * @author xx
     * @date 2024-03-18
     */
    public function importTestInsert(){
        $data   = $this->request->post();
        $res = (new LinXingOrderLogic())->import_order_lin_sku($data);
        return $this->jsonMessage(200, true, "推送成功!", null);
    }

    /**
     * @desc   shopify数据清洗
     * @author xx
     * @date 2024-07-10
     */
    public function shopifyChangePru(){
        $data  = $this->request->post();
        $res   = (new TestLogic())->shopifyChangePru($data);
        return $this->jsonMessage(200, true, "操作成功!", $res);
    }


    /**
     * @desc   shopify数据清洗
     * @author xx
     * @date 2024-07-10
     */
    public function shopify_change(){
        $data         = $this->request->post();
        $res          = (new TestLogic())->shopify_change($data);
        return $this->jsonMessage(200, true, "操作成功!", $res);
    }



    /**
     * @desc   测试订单发货
     * @author xx
     * @date   2024-03-29
     */
    public function testOrder(){
         $data   = $this->request->post();
         $res    =  (new OrderShipServiceLogic())->orderShippingQueueConsume($data);
         return $this->jsonMessage(200, true, "推送成功!", $res);
    }


    /**
     * @desc  tracking_number消费方法
     * @author xx
     * @date 2024-07-11
     */
    public function jinyi_tracking_number_consumer()
    {
        $params     = $this->request->post();
        $res        =  (new JinyiApiService())->tracking_number_update_consumer($params);
        return $this->jsonMessage(200, true, "推送成功!", $res);
    }


    /**
     * @desc  创建物流信息消费方法
     * @author xx
     * @date 2024-07-12
     */
    public function trackShopifyConsumer(){
        $params     = $this->request->post();
        $res        =  (new TestLogic())->trackShopify($params);
        return $this->jsonMessage(200, true, "获取成功!", $res);
    }

    /**
     * @desc   获取物流单号推送到shopify生产方法
     * @author luckyXiong
     * @date   2024-07-12
     */
    public function trackShopifyProduce(){
        $params     = $this->request->post();
        $res        =  (new TestLogic())->trackShopifyProduce($params);
        return $this->jsonMessage(200, true, "获取成功!", $res);
    }


    public function change_sku()
    {
        $params = $this->request->post();
        $sku = $params['order_id'] ?? '';
        (new TestLogic())->get_sku_info($sku);
        return $this->jsonMessage(200, true, "获取成功!", null);
    }


    /**
     * @desc   获取物流单号推送到shopify生产方法
     * @author luckyXiong
     * @date   2024-09-05
     */
    public function get_estimate_fee(){
        $params      = $this->request->post();
        $order_id    = $params['order_id'] ?? '';
        $info        = (new FreightLogic())->get_estimate_fee($order_id);
        return $this->jsonMessage(200, true, "获取成功!",$info);
    }


    /**
     * @desc   获取报告列表
     * @author luckyXiong
     * @date   2024-09-05
     */
    public function get_export_list(){
        $params      = $this->request->post();
        $info        = (new CommonExportCsvTaskLogService())->createCsvConsumer($params);
        return $this->jsonMessage(200, true, "获取成功!",$info);
    }


    /**
     * @desc   获取报告详情
     * @author luckyXiong
     * @date   2024-09-05
     */
    public function getSpuMonthConsumer(){
        $params      = $this->request->post();
        $info        = (new TestLogic())->spuMonthConsumer($params);
        return $this->jsonMessage(200, true, "获取成功!",$info);
    }



    /**
     * @desc   创建报告信息
     * @author luckyXiong
     * @date   2024-09-06
     */
    public function send_product_consumer(){
        $params      = $this->request->post();
        $info        = (new ShopifyListingLogic())->send_product_consumer($params);
        return $this->jsonMessage(200, true, "获取成功!",$info);
    }


    /**
     * @desc   获取历史产品信息
     * @author luckyXiong
     * @date   2024-09-06
     */
    public function get_product_consumer(){
        $params      = $this->request->post();
        $info        = (new ShopifyListingLogic())->get_product_consumer($params);
        return $this->jsonMessage(200, true, "获取成功!",$info);
    }

    /**
     * @desc   业绩数据
     * @author luckyXiong
     * @date   2024-09-09
     */
    public function get_spu_fee(){
        $params      = $this->request->post();
        $info        = (new ShopyLogic())->get_spu_fee();
        return $this->jsonMessage(200, true, "获取成功!",$info);
    }



    public function get_spu_price(){
        $params      = $this->request->post();
        $spu         = $params['spu']??'';
        $info        = (new OrderReportSkuLogic())->get_spu_price_info($spu);
        return $this->jsonMessage(200, true, "获取成功!",$info);
    }


    /**
     * @desc   测试发飞书消息
     * @author luckyXiong
     * @date   2024-09-11
     */
    public function test_send_message(){
        $params      = $this->request->post();
        $info        = (new ShopyLogic())->test_send_message($params);
        return $this->jsonMessage(200, true, "获取成功!",null);
    }

    /**
     * @desc   获取sku信息
     * @author luckyXiong
     * @date   2025-03-03
     */
    public function get_sku_info(){
        $params      = $this->request->post();
        $info        = (new ShopyLogic())->get_sku_info($params);
        return $this->jsonMessage(200, true, "获取成功!",$info);
    }



    /**
     * @desc   获取提成比例
     * @author luckyXiong
     * @date   2024-09-11
     */
    public function get_channel_rate(){
        $params      = $this->request->post();
        return  (new ShopyLogic())->get_channel_rate($params);
    }

    /**
     * @desc   获取是否组长判断
     * @author luckyXiong
     * @date   2024-09-20
     */
    public function get_team_info(){
        $params      = $this->request->post();
        return  (new ShopyLogic())->get_team_info($params);
    }

    /**
     * @desc    获取广告费用数据
     * @author  luckyXiong
     * @date    2024-09-20
     */
    public function get_advertistment(){
        $params      = $this->request->post();
        return  (new ShopyLogic())->get_advertistment_info($params);
    }


    /**
     * @desc    产品历史数据处理
     * @author  luckyXiong
     * @date    2024-12-06
     */
    public function product_history_produce(){
        $params      = $this->request->get();
        return  (new TestLogic())->product_history_produce($params);
    }


    /**
     * @desc    产品历史数据处理
     * @author  luckyXiong
     * @date    2025-04-01
     */
    public function test_hwc_order(){
        $params      = $this->request->post();
        (new testLogic())->test_hwc_order($params);
        return $this->jsonMessage(200, true, "获取成功!",'');
    }




    /**
     * @desc    产品历史数据处理
     * @author  luckyXiong
     * @date    2024-12-06
     */
    public function product_hwc_produce(){
        $params      = $this->request->get();
        return  (new TestLogic())->product_hwc_produce();
    }


    /**
     * @desc     更新token信息
     * @date     2024-11-07
     * @author   luckyXiong
     */
    public function getAnalyticsToken(){
        $params  = $this->request->post();
        $shop_id = $params['shop_id'];
        $res    = (new TeamLogic())->getAnalyticsToken($shop_id);
        return $this->jsonMessage(200,true,'操作成功',$res);
    }


    /**
     * @desc    产品历史数据处理
     * @author  luckyXiong
     * @date    2024-12-06
     */
    public function getVisitListDetail(){
        $params  = $this->request->post();
        (new TeamLogic())->getVisitListDetail($params);
        return $this->jsonMessage(200, true, "获取成功!",'');
    }


    /**
     * @desc    产品历史数据处理
     * @author  luckyXiong
     * @date    2024-12-06
     */
    public function purchase_suggest_plan(){
        $params  = $this->request->get();
        (new TeamLogic())->purchase_suggest_plan();
        return $this->jsonMessage(200, true, "获取成功!",'');
    }


    /**
     * @desc    备货建议数量spu
     * @author  luckyXiong
     * @date    2024-12-06
     */
    public function add_spu_plan(){
        $params  = $this->request->get();
        (new TeamLogic())->add_spu_plan();
        return $this->jsonMessage(200, true, "获取成功!",'');
    }


    /**
     * @desc    备货建议数量spu
     * @author  luckyXiong
     * @date    2024-12-06
     */
    public function add_test_order(){
        $params  = $this->request->get();
        (new OrderLogic())->test_order();
        return $this->jsonMessage(200, true, "获取成功!",'');
    }


    /**
     * @desc    备货建议数量spu
     * @author  luckyXiong
     * @date    2024-12-06
     */
    public function add_explode_info(){
        $params  = $this->request->post();
        (new OrderSplitLogic())->add_explode_detail($params);
        return $this->jsonMessage(200, true, "获取成功!",'');
    }

}


